package com.yanqu.road.server.cmd.activity.suoyao;

import com.yanqu.road.pb.activity.SuoYaoActivityProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.suoyao.SuoYaoMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C2_SUOYAO_ACTIVITY_HELP_CODE, desc = "锁妖塔补偿代码")
public class CrossSuoYaoHelpCodeCmd extends CrossCommand {

    int activityId;
    int type;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        SuoYaoActivityProto.CrossSuoYaoHelpCode msg = SuoYaoActivityProto.CrossSuoYaoHelpCode.parseFrom(packet.getBytes());
        activityId = msg.getActivityId();
        type = msg.getType();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        if (type == 1) {
            SuoYaoMgr.reloadConfig(activityId);
        } else if (type == 2) {
            SuoYaoMgr.repair(activityId);
        }
    }

    @Override
    public void sendData() {

    }
}
